﻿using System;
using UnityEngine;

namespace FrameWork.UICore
{
    /// <summary>
    /// ui层级
    /// </summary>
    public enum EUILayer
    {
        /// <summary>
        /// 自主管理层级
        /// </summary>
        None = 0,
        /// <summary>
        /// 主界面层
        /// </summary>
        MainUI = 1,
        /// <summary>
        /// 通用UI层
        /// </summary>
        CommonUI = 2,
        /// <summary>
        /// 通用弹窗层
        /// </summary>
        CommonPop = 3,
        /// <summary>
        /// 提示弹窗层
        /// </summary>
        TipPop = 4,
        /// <summary>
        /// 提示文本层
        /// </summary>
        Tips = 5,
        /// <summary>
        /// 系统提示层
        /// </summary>
        SystemTip = 6,
    }

    [AttributeUsage(AttributeTargets.Class)]
    public class UIMetaAttribute : Attribute
    {
        public readonly string Path;
        
        public readonly EUILayer UILayer;

        public readonly string UIName;

        public UIMetaAttribute(string path, EUILayer uiLayer, string uiName)
        {
             this.Path = path;
             this.UILayer = uiLayer;
             this.UIName = uiName;
        }
    }
    
    [DisallowMultipleComponent]
    public abstract class UIBase : MonoBehaviour
    {
        /// <summary>
        /// ui层级
        /// </summary>
        public static EUILayer UILayer { get; set; } = EUILayer.CommonUI;
        
        /// <summary>
        /// 名称
        /// </summary>
        public abstract string Name { get; }

        /// <summary>
        /// 当打开
        /// </summary>
        public abstract void OnOpen();

        /// <summary>
        /// 当隐藏
        /// </summary>
        public abstract void OnHide();
        
        /// <summary>
        /// 当恢复
        /// </summary>
        public abstract void OnRestore();
        
        /// <summary>
        /// 当关闭
        /// </summary>
        public abstract void OnClose();
    }
}